package com.itheima.health.controller;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.itheima.health.common.R;
import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.User;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Random;

@Slf4j
@RestController
@RequestMapping("/validateCode")
public class validateCodeController {

    private final HikariDataSource dataSource;

    public validateCodeController(HikariDataSource dataSource) {
        this.dataSource = dataSource;
    }

    @PostMapping("/send4Login")
    public R<String> sendMsg(  String  telephone,HttpSession session) throws Exception {
        Random random = new Random();
        //生成随机数
        int rannum = random.nextInt(9999)+1000;
        System.out.println(rannum);
        Sample.duanxin(telephone, String.valueOf(rannum));
        session.setAttribute("validateCode",rannum);
        return R.success("发送成功");

    }







}